package chapter10.h10_4;

public class BubbleSort implements Sorter {
    @Override
    public void sort(Comparable[] data) {
        for (int i = 0 ; i < data.length ; i++){
            boolean flag = false;
            for (int j = 0 ; j < data.length-i-1 ; j++){
                if (data[j].compareTo(data[j+1])==1){
                    Comparable temp = data[j];
                    data[j] = data[j+1];
                    data[j+1] = temp;
                    flag = true;
                }
            }
            if (!flag){
                break;
            }
        }
    }
}
